package work20241202_chap5oop.j_oop;

/**
 * @author zdl
 * @date 2024/12/2
 */
public class Demo12 {
    public static void main(String[] args) {
        Complex complex = new Complex(2,3);
        Complex add = complex.add(complex);
        System.out.println();

    }
}

class Complex{
    double real; // 实部
    double im; //虚部

    public Complex(double real,double im){
        this.real = real;
        this.im = im;
    }
    public Complex add(Complex c){
        double newReal = this.real + c.real;
        double newIm = this.im + c.im;
        return  new Complex(newReal,newIm);
    }
}
